/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.socialNet.manager;

import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.NamingException;

/**
 *
 * @author Ann
 */
public class ConnectionManager {
    
    private static ConnectionManager instance;
    private ConnectionPool connectionPool;
    
    private ConnectionManager() throws SQLException, NamingException {
        connectionPool = new ConnectionPool();
    }
    
    public static ConnectionManager getInstance() throws SQLException, NamingException {
        if (instance == null) {
            instance = new ConnectionManager();            
        }
        return instance;
    }
    
    public Connection getConnection() throws SQLException, NamingException {
        return connectionPool.getConnection();
    }
    
    public void freeConnection(Connection conn) throws SQLException {
        connectionPool.free(conn);
    }
}
